3

1.由于CentOS 的yum源中没有mysql,需要到mysql的官网下载yum repo配置文件。

wget http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

2.安装yum repo文件

rpm -ivh mysql57-community-release-el7-9.noarch.rpm

执行完成后会在/etc/yum.repos.d/目录下生成两个repo文件mysql-community.repo mysql-community-source.repo

3.然后更新yum缓存

yum clean all
yum makecache

4.安装mysql

yum install mysql-community-client.x86_64 mysql-community-common.x86_64 mysql-community-devel.x86_64 mysql-community-libs.x86_64 mysql-community-server.x86_64

或者

rpm install mysql-server

5.启动mysql

service mysqld start

6.查看初始密码

grep 'temporary password' /var/log/mysqld.log

得到如下内容:

2016-10-28T10:36:32.369073Z 1 [Note] A temporary password is generated for root@localhost: 5Oazqgpiat!p

7.使用初始密码登录

mysql -u root -p //回车,然后输入上一步查到的初始密码

8.更改初始密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
//现在的mysql对密码强度要求较高,需要包含大小写字母、数字和特殊字符

至此,mysql-server安装完成


我有切糕
863 声望45 粉丝

Java架构师,技术经理